﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using ChineseSchool.BLL;
using ChineseSchool.Models.Hethong;

namespace ChineseSchool
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.Title = "Học tiếng trung hiệu quả";
            if (!IsPostBack)
            {
                lblHotNews.Text = LoadHotNewsContent();
            }
        }

        public string LoadHotNewsContent()
        {
            string format = "ddd, dd/MM/yyyy h:mm:ss tt";
            string strNews = "";
            List<M_News> lstNews = (new B_News()).GetHotnews();
            if (lstNews != null && lstNews.Count > 0)
            {
                for (int j = 0; j < lstNews.Count; j++)
                {

                    strNews += "<article class=\"alt\">";
                    strNews += "<div class=\"newstitle\">";
                    strNews += "<div class=\"newstitle_img\">";
                    strNews += "<div class=\"featured-thumbnail\">";
                    strNews += "<a href=\"" + Util.MakeLinkNewsDetail(lstNews[j].newsID.ToString(), Encode.Uni2KD(lstNews[j].title.ToString())) + "\">";
                    strNews += "<img width=\"100\" height =\"60\" title=\"" + lstNews[j].title.ToString() + "\" alt=\"" + lstNews[j].title.ToString() + "\" class=\"attachment-medium-post-thumbnail wp-post-image\"";
                    strNews += " src=\"" + lstNews[j].imageUrl.ToString() + "\"/>";
                    strNews += "</a></div></div>";
                    strNews += "<div class=\"newstitle_imf\">";
                    strNews += "<h2 class=\"title\">";
                    strNews += "<a rel=\"Tin tức nổi bật\" title=\"" + lstNews[j].title.ToString() + "\" href=\"" + Util.MakeLinkNewsDetail(lstNews[j].newsID.ToString(), Encode.Uni2KD(lstNews[j].title.ToString())) + "\">";
                    strNews += "" + lstNews[j].title.ToString() + "</a></h2>";
                    strNews += "<div class=\"post-meta\">";
                    strNews += "<span class=\"post-date\">" + lstNews[j].postDate.ToString(format) + "</span> &nbsp; ";
                    strNews += " Posted by <a rel=\"author\" title=\"Posts by admin\" href=\"#\">admin</a>";
                    strNews += "</div></div>";
                    strNews += "</div>";
                    strNews += "<div class=\"clear\"></div>";
                    strNews += "<div class=\"post-excerpt\">";
                    strNews += "<div> " + lstNews[j].summary.ToString() + "&nbsp;";
                    strNews += " <a class=\"read-more\" ";
                    strNews += " href=\"" + Util.MakeLinkNewsDetail(lstNews[j].newsID.ToString(), Encode.Uni2KD(lstNews[j].title.ToString())) + "\">Xem Chi Tiết</a></div>";
                    strNews += "</div></article>";
                }
            }
            return strNews;
        }
    }
}